<template>
    <GFormCreator :conf="inputConf" ref="createForm">
        <template #default>
            <el-button @click="createUser" type="primary">立即创建</el-button>
            <el-button @click="reset">重置</el-button>
        </template>
    </GFormCreator>
</template>

<script>
import inputConf from "./inputPageConf"
import { createLoan } from "@/apis/loan.js"
export default {
    name: "loan-input",
    data() {
        return {
            inputConf
        };
    },
    methods: {
       /*async*/ createUser() {
            this.$refs.createForm.validate(async data => {
                if (!data) return this.$message.error("表单验证不通过");
                console.log("数据：", data);
                // var data = {
                //     "name": "xp19",
                //     "birthday": "2022-07-10T16:00:00.000Z",
                //     "sex": "man",
                //     "identity_card": "444",
                //     "marriage": "married",
                //     "education": "college",
                //     "address1": "武汉",
                //     "address2": "武汉",
                //     "phone": "8123",
                //     "mobile_phone": "123",
                //     "company": "金渡",
                //     "trade": "education",
                //     "position": "1",
                //     "address3": "2",
                //     "company_type": "3",
                //     "company_email": "4",
                //     "company_phone": "5",
                //     "income": "6",
                //     "contact": "7",
                //     "contact_name": "8",
                //     "contact_phone": "9",
                //     "contact2": "11",
                //     "contact2_name": "12",
                //     "contact2_phone": "13",
                //     "contact2_dep": "14",
                //     "contact2_pos": "15",
                //     "remark": "111"
                // }
                let [res, err] = await createLoan(data)
                if (err) return this.$message.error("创建用户失败")
                console.log(res);
                if (res.data.code == 2000) {
                    this.$message.success("创建用户成功")
                }
            })
        },
        reset() {
            this.$refs.createForm.reset();
        }
    }
};
</script>

<style lang="scss" scoped>
</style>